const findMaxForm = function(strs, m, n) {
    let dp = new Array(m+1)
    for (let i = 0; i < dp.length; i++) {
        dp[i] = new Array(n+1);
        dp[i].fill(0);
    }
    for (let i = 0; i < strs.length; i++) {
        let zero = count(strs[i], '0'), one = count(strs[i], '1');
        for (let j = m; j >= zero; j--) {
            for (let k = n; k >= one; k--) {
                dp[j][k] = Math.max(dp[j][k], dp[j-zero][k-one] + 1)
            }
        }
    }
    function count (str, c) {
        var count = 0;
        for (let i = 0; i < str.length; i++) {
            if (str[i] === c) {
                count++;
            }
        }
        return count;
    }
    return dp[m][n];
};

console.log(findMaxForm(["10", "0001", "111001", "1", "0"], 5, 3));